import { setupLayouts } from 'virtual:meta-layouts'
import generatedRoutes from 'virtual:generated-pages'
import type { RouteRecordRaw } from 'vue-router'
// import MultilevelMenuExample from './modules/multilevel.menu.example'
import type { Route } from '#/global'
import { $t } from '@/locales'
import useSettingsStore from '@/store/modules/settings'



 


// 固定路由（默认路由）
const constantRoutes : RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login.vue'),
    meta: {
      whiteList: true,
      title: '登录',
      i18n: $t('route.login'),
    },
  },
  {
    path: '/:all(.*)*',
    name: 'notFound',
    component: () => import('@/views/[...all].vue'),
    meta: {
      title: '找不到页面',
    },
  },
]

// 系统路由
const systemRoutes : RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('@/layouts/index.vue'),
    meta: {
      title: () => useSettingsStore().settings.home.title,
      breadcrumb: false,
    },
    children: [
      {
        path: '',
        component: () => import('@/views/index.vue'),
        meta: {
          title: () => useSettingsStore().settings.home.title,
          i18n: $t('route.home'),
          icon: 'i-ant-design:home-twotone',
          breadcrumb: false,
        },
      },
      {
        path: 'reload',
        name: 'reload',
        component: () => import('@/views/reload.vue'),
        meta: {
          title: '重新加载',
          breadcrumb: false,
        },
      },
      {
        path: 'personal/notification',
        name: 'personalNotification',
        component: () => import('@/views/personal/notification.vue'),
        meta: {
          title: '通知中心',
          i18n: $t('route.personal.notification'),
        },
      },
    ],
  },
]

// 动态路由（异步路由、导航栏路由）
const asyncRoutes: Route.recordMainRaw[] = [
	{
		meta: {
	    title: '首页',
	    // i18n: $t('route.ecology'),
	    icon: 'i-ri:database-2-line',
	  },
	  children: [
	    // Index,
	  ],
	},
	{  
		meta: {
	    title: '客户',
	    // i18n: $t('route.ecology'),
	    icon: 'i-icon-park-outline:circular-connection',
	  },
	  children: [
		  // User,
		  // Custom,
	  ],
	},
	{
		meta: {
	    title: '员工',
	    // i18n: $t('route.ecology'),
	    icon: 'i-ri:notification-badge-line',
	  },
	  children: [
		  // Staff,
		  // Position,
	  ],
	},
	{
		meta: {
	    title: '统计',
	    // i18n: $t('route.ecology'),
	    icon: 'i-ant-design:home-twotone',
	  },
	  children: [
		  // Datas
	  ],
	},
	{
		meta: {
	    title: '营销',
	    // i18n: $t('route.ecology'),
	    icon: 'i-bx:bxs-component',
	  },
	  children: [
		  // Friends,
		  // Article,
		  // Publicize
	  ],
	},
	{
		meta: {
	    title: '内容',
	    // i18n: $t('route.ecology'),
	    icon: 'i-ant-design:home-twotone',
	  },
	  children: [
		  // Product,
		  // Case,
		  // Gallery,
		  // Galleryss
	  ],
	},
	{
		meta: {
	    title: '企业',
	    // i18n: $t('route.ecology'),
	    icon: 'i-bi:layout-three-columns',
	  },
	  children: [
		  // Message,
		  // Paymoney,
		  // Mallset
	  ],
	},
	// {
	// 	meta: {
	//     title: '设置',
	//     // i18n: $t('route.ecology'),
	//     icon: 'i-material-symbols:qr-code',
	//   },
	//   children: [
	// 	  Setup,
	//   ],
	// },
	// {
	// 	meta: {
	//     title: '系统管理',
	//     icon: 'i-bi:layout-three-columns',
	//   },
	//   children: [
	    
	//   ],
	// }
]

const constantRoutesByFilesystem = generatedRoutes.filter((item) => {
  return item.meta?.enabled !== false && item.meta?.constant === true
})

const asyncRoutesByFilesystem = setupLayouts(generatedRoutes.filter((item) => {
  return item.meta?.enabled !== false && item.meta?.constant !== true && item.meta?.layout !== false
}))

export {
  constantRoutes,
  systemRoutes,
  asyncRoutes,
  constantRoutesByFilesystem,
  asyncRoutesByFilesystem,
}
